package com.wtwd.campus.h5_manager.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wtwd.campus.h5_manager.entity.H5ManageUser;
import com.wtwd.campus.h5_manager.entity.vo.H5ManageUserVo;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author mjy
 * @since 2022-03-04
 */
public interface H5ManagerUserService {

    H5ManageUser getSysUserByAccount(String account);

    Boolean checkLoginUser(H5ManageUser sysUser, String password);

    /**
     * 存储redis
     * 存储形式
     * key token  value  flag
     * key flag   value  map(userId,currentToken)
     * currentToken 做单点登录时使用
     *
     * @param flag
     * @param userId
     * @param tokenExpire
     * @param minutes
     * @return
     */
    String createUserToken(String flag, Integer userId, long tokenExpire, TimeUnit minutes);

    Integer getUserIdByToken(String token) throws IllegalArgumentException;

    Map<String, Object> getUserMapByToken(String token);

    H5ManageUser getUserById(Integer userId);

    Integer deleteByCustomerId(Integer customerId);

    Integer deleteByRoleId(Integer roleId);

    IPage<H5ManageUser> getUserPageByCustomerId(Integer customerId, Page<H5ManageUser> page);

    IPage<H5ManageUserVo> getUserPageByConditions(H5ManageUser userSearch, Page<H5ManageUser> page);

    Boolean authUserName(H5ManageUser manageUserVo);

    Integer insertUser(H5ManageUser manageUser);

    Integer updateAccount(H5ManageUser manageUserVo);

    /**
     * 删除用户的同时删除,移除用户 key
     *
     * @param userId
     * @return
     */
    Integer deleteByUserId(Integer userId);
}
